*Run this do-file to clean all data, run analyses, and produce tables and figures*

clear
clear matrix
clear mata
set matsize 10000
set maxvar 10000
set more off

// Set your working directory to the location of the main repository

////////////////////////////////////////////////////////////////////////////////
*Globals for directories
////////////////////////////////////////////////////////////////////////////////
global main "`c(pwd)'"
global code "$main/code"
global data "$main/data"

foreach dir in uk us germany europe other {
	cap mkdir "$main/data/`dir'/temp"
	cap mkdir "$main/data/`dir'/clean"
}

global ukdata "$main/data/uk"
global usdata "$main/data/us"
global germanydata "$main/data/germany"
global europedata "$main/data/europe"
global otherdata "$main/data/other"

global ukgraphics "$main/graphics/uk"
global usgraphics "$main/graphics/us"
global germanygraphics "$main/graphics/germany"
global othergraphics "$main/graphics/other"

global tables "$main/tables"

////////////////////////////////////////////////////////////////////////////////
*Run do-file containing the programs and packages needed to run the rest of the code
////////////////////////////////////////////////////////////////////////////////

do "$code/programs.do"

////////////////////////////////////////////////////////////////////////////////
*Cleaning data--with a few exceptions, the raw files necessary for these do-files to run are not included in this replication package. Instructions on how to download the raw data we use in our analysis are located in the README file in the main replication package folder.*
////////////////////////////////////////////////////////////////////////////////


do "$code/1_ukdata_cleaning.do"

do "$code/2_usdata_cleaning.do"

do "$code/3_germanydata_cleaning.do"

do "$code/4_europedata_cleaning.do"

do "$code/5_scopus_nlp_cleaning.do"


////////////////////////////////////////////////////////////////////////////////
*Produce all main text figures (Figures 1-5)
////////////////////////////////////////////////////////////////////////////////

do "$code/6_figures.do"

////////////////////////////////////////////////////////////////////////////////
*Produce main text summary statistics tables (Tables 1 and 6)
////////////////////////////////////////////////////////////////////////////////

do "$code/7_tables.do"

////////////////////////////////////////////////////////////////////////////////
*Main text regression analysis w/ Tables 2-5, 7, as well as Figures C.1-C.4, F.1-F.7, and H.1-H.3, and Table F.1
////////////////////////////////////////////////////////////////////////////////

do "$code/8_regressions_jobsecurity.do"

do "$code/9_regressions_other.do"

////////////////////////////////////////////////////////////////////////////////
*Produce all remaining appendix figures and tables
////////////////////////////////////////////////////////////////////////////////

do "$code/appendix_a"

do "$code/appendix_b"

do "$code/appendix_c" // Figures C.1-C.4 are produced by "regressions_jobsecurity.do"

do "$code/appendix_e"

do "$code/appendix_g"